#include "cocos2d.h"
extern "C" {
#include "lua.h"
}
#include "xxtea/xxtea.h"
#include "CCLuaEngine.h"
#include "HelperFunc.h"
#include "extend/FileDecoder.h"

USING_NS_CC;


int HelperFunc::getFileData(const char *pPathFile)
{
    Data data = FileUtils::getInstance()->getDataFromFile(pPathFile);
    unsigned long size = data.getSize();
    unsigned char* buf = data.getBytes();
    
    Data outData;
    if(FileDecoder::decode(data,outData))
    {
        size = outData.getSize();
        buf = outData.getBytes();
    }


    LuaStack* stack = LuaEngine::getInstance()->getLuaStack();
	stack->clean();
    if (buf) {
        stack->pushString((const char*)(buf), (int)size);
    } else {
        stack->pushNil();
    }
    return 1;
}
